<html>
<head><meta charset="utf-8"><title>What is `ext/build.rs`? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html">What is `ext/build.rs`?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="176275903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176275903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176275903">(Sep 21 2019 at 18:41)</a>:</h4>
<p>I am looking at <code>ext/build.rs</code> and I am not sure what it does. I've tried commenting out it's method (<code>item_use_list</code>), but <code>cargo check</code> passed successfully after that. Is this something related to old syntax-based compiler plugins, which we want to remove anyway? Could we get rid of this thing or trim it down? ^^ cc  <span class="user-mention" data-user-id="116122">@simulacrum</span>, I think you've recently touched this code</p>



<a name="176275961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176275961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176275961">(Sep 21 2019 at 18:43)</a>:</h4>
<p>I believe it's the helper code that's used by the built-in derives and macros for expansion...</p>



<a name="176275971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176275971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176275971">(Sep 21 2019 at 18:43)</a>:</h4>
<p>Probably some of it isn't necessarily currently used though (not sure if I'd delete it; we might want it again)</p>



<a name="176276034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276034">(Sep 21 2019 at 18:45)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> hm, actually, that module might be entirely unused now</p>



<a name="176276115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276115">(Sep 21 2019 at 18:47)</a>:</h4>
<p>aha, no, I do get at least one error if I delete it entirely...</p>



<a name="176276131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276131">(Sep 21 2019 at 18:47)</a>:</h4>
<p>and if you commment it out, there's a bunch of usages</p>



<a name="176276171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276171">(Sep 21 2019 at 18:48)</a>:</h4>
<p>deriving/generic/mod.rs for one</p>



<a name="176276186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276186">(Sep 21 2019 at 18:49)</a>:</h4>
<p>I guess, long term, we want to transition built-in macros to token model and remove the thing?</p>



<a name="176276197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276197">(Sep 21 2019 at 18:49)</a>:</h4>
<p>hm, probably? It seems like most of it is basically just helpers -- probably replaceable with e.g. <code>quote!</code> or something like it from syn</p>



<a name="176276204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276204">(Sep 21 2019 at 18:49)</a>:</h4>
<p>I suspect it's probably mostly removable today</p>



<a name="176276269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276269">(Sep 21 2019 at 18:50)</a>:</h4>
<p>and it can definitely be decoupled from ExtCtxt I think</p>



<a name="176276275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276275">(Sep 21 2019 at 18:51)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> Do you ask for just "cleanup" or with some goal in mind?</p>



<a name="176276288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276288">(Sep 21 2019 at 18:51)</a>:</h4>
<p>just cleanup</p>



<a name="176276300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276300">(Sep 21 2019 at 18:51)</a>:</h4>
<p>yeah I'd probably leave it for now -- we can move it into src/libsyntax_ext though as free standing functions, though it's probably just needless churn</p>



<a name="176276347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276347">(Sep 21 2019 at 18:52)</a>:</h4>
<p>(but which probably would be required for long-term goal of syntax librarification: seems like making sure that everything uses token streams as much as possible should make extraction easier, as token streams are much simpler than AST)</p>



<a name="176276383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276383">(Sep 21 2019 at 18:53)</a>:</h4>
<p>I think a good first step to removing it would be to 'inline' portions of it -- particularly where it's pretty useless</p>



<a name="176276389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276389">(Sep 21 2019 at 18:53)</a>:</h4>
<p>e.g. most of the attr methods are just calling <code>attr::&lt;same name&gt;(&lt;same args&gt;)</code> which is largely unnecessary IMO</p>



<a name="176276665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276665">(Sep 21 2019 at 19:01)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> If you don't mind, I could take a look at some clean up to it?</p>



<a name="176276718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276718">(Sep 21 2019 at 19:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> sure, feel free do go ahead! I've just read this by accident: the thing I really want to do is to make sure that macro by example doesn't loose jointness info</p>



<a name="176276782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176276782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176276782">(Sep 21 2019 at 19:04)</a>:</h4>
<p>(poking into various bits of libsyntax make me feel like those blind philosophers touching an elephant, but with a yak instead of an elephant)</p>



<a name="176278819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/What%20is%20%60ext/build.rs%60%3F/near/176278819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/What.20is.20.60ext.2Fbuild.2Ers.60.3F.html#176278819">(Sep 21 2019 at 20:02)</a>:</h4>
<p>The goal is to eventually migrate built-in macros in <code>libsytnax_ext</code> to token-based model and use some form of <code>quote!</code> for building their output (probably generating internal libsyntax <code>TokenStream</code>, rather than <code>proc_macro::TokenStream</code>, at least for a start.)<br>
After that we'll be able to remove <code>syntax/ext/build.rs</code>, which kind of serves the same goal as <code>quote!</code>, but in AST-based world.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>